diff --git a/CHANGELOG b/CHANGELOG
index 6ea62a4..b607f87 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,18 @@
 Changes for U-Boot 1.0.0:
 ======================================================================
 
+* Patch by Martin Krause, 09 Oct 2003:
+  Fixes for TRAB board
+  - /board/trab/rs485.c: correct baudrate
+  - /board/trab/cmd_trab.c: bug fix for problem with timer overflow in 
+    udelay(); fix some timing problems with adc controller
+  - /board/trab/trab_fkt.c: add new commands: gain, eeprom and power;
+    modify commands: touch and buzzer
+
+* Disable CONFIG_SUPPORT_VFAT when used with CONFIG_AUTO_UPDATE
+  (quick & dirty workaround for rogue pointer problem in get_vfatname());
+  Use direct function calls for auto_update instead of hush commands
+
 * Patch by Scott McNutt, 04 Oct 2003:
   - add support for Altera Nios-32 CPU
   - add support for Nios Cyclone Development Kit (DK-1C20)
diff --git a/board/trab/auto_update.c b/board/trab/auto_update.c
index f44b9bf..345d2d4 100644
--- a/board/trab/auto_update.c
+++ b/board/trab/auto_update.c
@@ -183,9 +183,7 @@
 #define FIDX_TO_LIDX(idx) ((idx) - 2)
 
 /* where to load files into memory */
-#define LOAD_ADDR ((unsigned char *)0x0C100100)
-/* where to build strings in memory - 256 bytes should be enough */
-#define STRING_ADDR ((char *)0x0C100000)
+#define LOAD_ADDR ((unsigned char *)0x0C100000)
 /* the app is the largest image */
 #define MAX_LOADSZ ausize[IDX_APP]
 
@@ -199,6 +197,9 @@
 extern int trab_vfd (ulong);
 extern int transfer_pic(unsigned char, unsigned char *, int, int);
 #endif
+extern int flash_sect_erase(ulong, ulong);
+extern int flash_sect_protect (int, ulong, ulong);
+extern int flash_write (uchar *, ulong, ulong);
 /* change char* to void* to shutup the compiler */
 extern int i2c_write_multiple (uchar, uint, int, void *, int);
 extern int i2c_read_multiple (uchar, uint, int, void *, int);
@@ -305,13 +306,12 @@
 #define POWER_OFF (1 << 1)
 
 int
-au_do_update(int idx, long sz, int repeat)
+au_do_update(int idx, long sz)
 {
 	image_header_t *hdr;
 	char *addr;
 	long start, end;
-	char *strbuf = STRING_ADDR;
-	int off;
+	int off, rc;
 	uint nbytes;
 
 	hdr = (image_header_t *)LOAD_ADDR;
@@ -342,20 +342,14 @@
 		start = aufl_layout[1].start;
 		end = aufl_layout[1].end;
 #endif
-		debug ("protect off %lx %lx\n", start, end);
-		sprintf(strbuf, "protect off %lx %lx\n", start, end);
-		parse_string_outer(strbuf, FLAG_PARSE_SEMICOLON);
+		flash_sect_protect(0, start, end);
 	}
 
 	/*
-	 * erase the address range. Multiple erases seem to cause
-	 * problems.
+	 * erase the address range.
 	 */
-	if (repeat == 0) {
-		debug ("erase %lx %lx\n", start, end);
-		sprintf(strbuf, "erase %lx %lx\n", start, end);
-		parse_string_outer(strbuf, FLAG_PARSE_SEMICOLON);
-	}
+	debug ("flash_sect_erase(%lx, %lx);\n", start, end);
+	flash_sect_erase(start, end);
 	wait_ms(100);
 	/* strip the header - except for the kernel and app */
 	if (idx == IDX_FIRMWARE || idx == IDX_DISK) {
@@ -374,9 +368,12 @@
 	}
 
 	/* copy the data from RAM to FLASH */
-	debug ("cp.b %p %lx %x\n", addr, start, nbytes);
-	sprintf(strbuf, "cp.b %p %lx %x\n", addr, start, nbytes);
-	parse_string_outer(strbuf, FLAG_PARSE_SEMICOLON);
+	debug ("flash_write(%p, %lx %x)\n", addr, start, nbytes);
+	rc = flash_write(addr, start, nbytes);
+	if (rc != 0) {
+		printf("Flashing failed due to error %d\n", rc);
+		return -1;
+	}
 
 	/* check the dcrc of the copy */
 	if (crc32 (0, (char *)(start + off), ntohl(hdr->ih_size)) != ntohl(hdr->ih_dcrc)) {
@@ -386,11 +383,8 @@
 
 	/* protect the address range */
 	/* this assumes that ONLY the firmware is protected! */
-	if (idx == IDX_FIRMWARE) {
-		debug ("protect on %lx %lx\n", start, end);
-		sprintf(strbuf, "protect on %lx %lx\n", start, end);
-		parse_string_outer(strbuf, FLAG_PARSE_SEMICOLON);
-	}
+	if (idx == IDX_FIRMWARE)
+		flash_sect_protect(1, start, end);
 	return 0;
 }
 
@@ -587,7 +581,7 @@
 		cnt = 0;
 		got_ctrlc = 0;
 		do {
-			res = au_do_update(i, sz, cnt);
+			res = au_do_update(i, sz);
 			/* let the user break out of the loop */
 			if (ctrlc() || had_ctrlc()) {
 				clear_ctrlc();
diff --git a/board/trab/cmd_trab.c b/board/trab/cmd_trab.c
index 78e14bd..509e071 100644
--- a/board/trab/cmd_trab.c
+++ b/board/trab/cmd_trab.c
@@ -21,6 +21,8 @@
  * MA 02111-1307 USA
  */
 
+#undef DEBUG
+
 #include <common.h>
 #include <command.h>
 #include <s3c2400.h>
@@ -71,7 +73,7 @@
 #define I2C_EEPROM_DEV_ADDR     0x54
 
 /* EEPROM address map */
-#define EE_ADDR_TEST                    128
+#define EE_ADDR_TEST                    192
 #define EE_ADDR_MAX_CYCLES              256
 #define EE_ADDR_STATUS                  258
 #define EE_ADDR_PASS_CYCLES             259
@@ -148,7 +150,7 @@
 
 typedef struct test_function_s {
 	unsigned char *name;
-        int (*pf)(void);
+	int (*pf)(void);
 } test_function_t;
 
 /* max number of Burn In Functions */
@@ -160,245 +162,251 @@
 
 int do_burn_in (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-        int i;
-        int cycle_status;
+	int i;
+	int cycle_status;
 
-        if (argc > 1) {
+	if (argc > 1) {
 		printf ("Usage:\n%s\n", cmdtp->usage);
 		return 1;
 	}
 
-        led_init ();
-        global_vars_init ();
-        test_function_table_init ();
+	led_init ();
+	global_vars_init ();
+	test_function_table_init ();
 
-        if (global_vars_write_to_eeprom () != 0) {
-                printf ("%s: error writing global_vars to eeprom\n",
-                        __FUNCTION__);
-                return (1);
-        }
+	if (global_vars_write_to_eeprom () != 0) {
+		printf ("%s: error writing global_vars to eeprom\n",
+			__FUNCTION__);
+		return (1);
+	}
 
-        if (read_max_cycles () != 0) {
-                printf ("%s: error reading max_cycles from eeprom\n",
-                        __FUNCTION__);
-                return (1);
-        }
+	if (read_max_cycles () != 0) {
+		printf ("%s: error reading max_cycles from eeprom\n",
+			__FUNCTION__);
+		return (1);
+	}
 
-        if (max_cycles == 0) {
-                printf ("%s: error, burn in max_cycles = 0\n", __FUNCTION__);
-                return (1);
-        }
+	if (max_cycles == 0) {
+		printf ("%s: error, burn in max_cycles = 0\n", __FUNCTION__);
+		return (1);
+	}
 
-        status = 0;
-        for (act_cycle = 1; act_cycle <= max_cycles; act_cycle++) {
+	status = 0;
+	for (act_cycle = 1; act_cycle <= max_cycles; act_cycle++) {
 
-                cycle_status = 0;
-                for (i = 0; i < BIF_MAX; i++) {
+		cycle_status = 0;
 
-                        /* call test function */
-                        if ((*test_function[i].pf)() != 0) {
-                                printf ("error in %s test\n",
-                                        test_function[i].name);
+		/*
+		 * avoid timestamp overflow problem after about 68 minutes of
+		 * udelay() time.
+		 */
+		reset_timer_masked ();
+		for (i = 0; i < BIF_MAX; i++) {
 
-                                /* is it the first error? */
-                                if (status == 0) {
-                                        status = 1;
-                                        first_error_cycle = act_cycle;
+			/* call test function */
+			if ((*test_function[i].pf)() != 0) {
+				printf ("error in %s test\n",
+					test_function[i].name);
 
-                                        /* do not use error_num 0 */
-                                        first_error_num = i+1;
-                                        strncpy (first_error_name,
-                                                 test_function[i].name,
-                                                 sizeof (first_error_name));
-                                        led_set (0);
-                                }
-                                cycle_status = 1;
-                        }
-                }
-                /* were all tests of actual cycle OK? */
-                if (cycle_status == 0)
-                        pass_cycles++;
+				/* is it the first error? */
+				if (status == 0) {
+					status = 1;
+					first_error_cycle = act_cycle;
 
-                /* set status LED if no error is occoured since yet */
-                if (status == 0)
-                        led_set (1);
+					/* do not use error_num 0 */
+					first_error_num = i+1;
+					strncpy (first_error_name,
+						 test_function[i].name,
+						 sizeof (first_error_name));
+					led_set (0);
+				}
+				cycle_status = 1;
+			}
+		}
+		/* were all tests of actual cycle OK? */
+		if (cycle_status == 0)
+			pass_cycles++;
 
-                printf ("%s: cycle %d finished\n", __FUNCTION__, act_cycle);
+		/* set status LED if no error is occoured since yet */
+		if (status == 0)
+			led_set (1);
 
-                /* pause between cycles */
-                sdelay (BURN_IN_CYCLE_DELAY);
-        }
+		printf ("%s: cycle %d finished\n", __FUNCTION__, act_cycle);
 
-        if (global_vars_write_to_eeprom () != 0) {
-                led_set (0);
-                printf ("%s: error writing global_vars to eeprom\n",
-                        __FUNCTION__);
-                status = 1;
-        }
+		/* pause between cycles */
+		sdelay (BURN_IN_CYCLE_DELAY);
+	}
 
-        if (status == 0) {
-                led_blink ();   /* endless loop!! */
-                return (0);
-        } else {
-                led_set (0);
-                return (1);
-        }
+	if (global_vars_write_to_eeprom () != 0) {
+		led_set (0);
+		printf ("%s: error writing global_vars to eeprom\n",
+			__FUNCTION__);
+		status = 1;
+	}
+
+	if (status == 0) {
+		led_blink ();   /* endless loop!! */
+		return (0);
+	} else {
+		led_set (0);
+		return (1);
+	}
 }
 
 U_BOOT_CMD(
- 	burn_in,	1,	1,	do_burn_in,
- 	"burn_in - start burn-in test application on TRAB\n",
- 	"\n"
- 	"    -  start burn-in test application\n"
-        "       The burn-in test could took a while to finish!\n"
-        "       The content of the onboard EEPROM is modified!\n"
+	burn_in,	1,	1,	do_burn_in,
+	"burn_in - start burn-in test application on TRAB\n",
+	"\n"
+	"    -  start burn-in test application\n"
+	"       The burn-in test could took a while to finish!\n"
+	"       The content of the onboard EEPROM is modified!\n"
 );
 
 
 int do_dip (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-        int i, dip;
+	int i, dip;
 
-      	if (argc > 1) {
+	if (argc > 1) {
 		printf ("Usage:\n%s\n", cmdtp->usage);
 		return 1;
 	}
 
-        if ((dip = read_dip ()) == -1) {
-                return 1;
-        }
+	if ((dip = read_dip ()) == -1) {
+		return 1;
+	}
 
-        for (i = 0; i < 4; i++) {
-                if ((dip & (1 << i)) == 0)
-                        printf("0");
-                else
-                        printf("1");
-        }
-        printf("\n");
+	for (i = 0; i < 4; i++) {
+		if ((dip & (1 << i)) == 0)
+			printf("0");
+		else
+			printf("1");
+	}
+	printf("\n");
 
 	return 0;
 }
 
 U_BOOT_CMD(
- 	dip,	1,	1,	do_dip,
- 	"dip     - read dip switch on TRAB\n",
- 	"\n"
- 	"    - read state of dip switch (S1) on TRAB board\n"
-        "      read sequence: 1-2-3-4; ON=1; OFF=0; e.g.: \"0100\"\n"
+	dip,	1,	1,	do_dip,
+	"dip     - read dip switch on TRAB\n",
+	"\n"
+	"    - read state of dip switch (S1) on TRAB board\n"
+	"      read sequence: 1-2-3-4; ON=1; OFF=0; e.g.: \"0100\"\n"
 );
 
 
 int do_vcc5v (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-        int vcc5v;
+	int vcc5v;
 
-        if (argc > 1) {
+	if (argc > 1) {
 		printf ("Usage:\n%s\n", cmdtp->usage);
 		return 1;
 	}
 
-        if ((vcc5v = read_vcc5v ()) == -1) {
-                return (1);
-        }
+	if ((vcc5v = read_vcc5v ()) == -1) {
+		return (1);
+	}
 
-        printf ("%d", (vcc5v / 1000));
-        printf (".%d", (vcc5v % 1000) / 100);
-        printf ("%d V\n", (vcc5v % 100) / 10) ;
+	printf ("%d", (vcc5v / 1000));
+	printf (".%d", (vcc5v % 1000) / 100);
+	printf ("%d V\n", (vcc5v % 100) / 10) ;
 
 	return 0;
 }
 
 U_BOOT_CMD(
- 	vcc5v,	1,	1,	do_vcc5v,
- 	"vcc5v   - read VCC5V on TRAB\n",
- 	"\n"
- 	"    - read actual value of voltage VCC5V\n"
+	vcc5v,	1,	1,	do_vcc5v,
+	"vcc5v   - read VCC5V on TRAB\n",
+	"\n"
+	"    - read actual value of voltage VCC5V\n"
 );
 
 
 int do_contact_temp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-        int contact_temp;
+	int contact_temp;
 
-        if (argc > 1) {
+	if (argc > 1) {
 		printf ("Usage:\n%s\n", cmdtp->usage);
 		return 1;
 	}
 
-        spi_init ();
-        tsc2000_reg_init ();
+	spi_init ();
+	tsc2000_reg_init ();
 
-        contact_temp = tsc2000_contact_temp();
-        printf ("%d degree C * 100\n", contact_temp) ;
+	contact_temp = tsc2000_contact_temp();
+	printf ("%d degree C * 100\n", contact_temp) ;
 
 	return 0;
 }
 
 U_BOOT_CMD(
- 	c_temp,	1,	1,	do_contact_temp,
- 	"c_temp  - read contact temperature on TRAB\n",
- 	"\n"
- 	"    -  reads the onboard temperature (=contact temperature)\n"
+	c_temp,	1,	1,	do_contact_temp,
+	"c_temp  - read contact temperature on TRAB\n",
+	"\n"
+	"    -  reads the onboard temperature (=contact temperature)\n"
 );
 
 
 int do_burn_in_status (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-        if (argc > 1) {
+	if (argc > 1) {
 		printf ("Usage:\n%s\n", cmdtp->usage);
 		return 1;
 	}
 
-        if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_STATUS, 1,
-                                (unsigned char*) &status, 1)) {
-                return (1);
-        }
-        if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_PASS_CYCLES, 1,
-                                (unsigned char*) &pass_cycles, 2)) {
-                return (1);
-        }
-        if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_CYCLE,
-                                1, (unsigned char*) &first_error_cycle, 2)) {
-                return (1);
-        }
-        if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NUM,
-                                1, (unsigned char*) &first_error_num, 1)) {
-                return (1);
-        }
-        if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NAME,
-                               1, first_error_name,
-                               sizeof (first_error_name))) {
-                return (1);
-        }
+	if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_STATUS, 1,
+				(unsigned char*) &status, 1)) {
+		return (1);
+	}
+	if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_PASS_CYCLES, 1,
+				(unsigned char*) &pass_cycles, 2)) {
+		return (1);
+	}
+	if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_CYCLE,
+				1, (unsigned char*) &first_error_cycle, 2)) {
+		return (1);
+	}
+	if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NUM,
+				1, (unsigned char*) &first_error_num, 1)) {
+		return (1);
+	}
+	if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NAME,
+			       1, first_error_name,
+			       sizeof (first_error_name))) {
+		return (1);
+	}
 
-        if (read_max_cycles () != 0) {
-                return (1);
-        }
+	if (read_max_cycles () != 0) {
+		return (1);
+	}
 
-        printf ("max_cycles = %d\n", max_cycles);
-        printf ("status = %d\n", status);
-        printf ("pass_cycles = %d\n", pass_cycles);
-        printf ("first_error_cycle = %d\n", first_error_cycle);
-        printf ("first_error_num = %d\n", first_error_num);
-        printf ("first_error_name = %.*s\n",(int) sizeof(first_error_name),
-                first_error_name);
+	printf ("max_cycles = %d\n", max_cycles);
+	printf ("status = %d\n", status);
+	printf ("pass_cycles = %d\n", pass_cycles);
+	printf ("first_error_cycle = %d\n", first_error_cycle);
+	printf ("first_error_num = %d\n", first_error_num);
+	printf ("first_error_name = %.*s\n",(int) sizeof(first_error_name),
+		first_error_name);
 
 	return 0;
 }
 
 U_BOOT_CMD(
- 	bis,	1,	1,	do_burn_in_status,
- 	"bis     - print burn in status on TRAB\n",
- 	"\n"
- 	"    -  prints the status variables of the last burn in test\n"
-        "       stored in the onboard EEPROM on TRAB board\n"
+	bis,	1,	1,	do_burn_in_status,
+	"bis     - print burn in status on TRAB\n",
+	"\n"
+	"    -  prints the status variables of the last burn in test\n"
+	"       stored in the onboard EEPROM on TRAB board\n"
 );
 
 static int read_dip (void)
 {
-        unsigned int result = 0;
-        int adc_val;
-        int i;
+	unsigned int result = 0;
+	int adc_val;
+	int i;
 
 	/***********************************************************
 	 DIP switch connection (according to wa4-cpu.sp.301.pdf, page 3):
@@ -413,11 +421,11 @@
 
 	for (i = 7; i > 3; i--) {
 
-                if ((adc_val = adc_read (i)) == -1) {
-                        printf ("%s: Channel %d could not be read\n",
-                                 __FUNCTION__, i);
-                        return (-1);
-                }
+		if ((adc_val = adc_read (i)) == -1) {
+			printf ("%s: Channel %d could not be read\n",
+				 __FUNCTION__, i);
+			return (-1);
+		}
 
 		/*
 		 * Input voltage (switch open) is 1.8 V.
@@ -425,397 +433,410 @@
 		 * Set trigger at halve that value.
 		 */
 		if (adc_val < 368)
-                        result |= (1 << (i-4));
-        }
-        return (result);
+			result |= (1 << (i-4));
+	}
+	return (result);
 }
 
 
 static int read_vcc5v (void)
 {
-        s32 result;
+	s32 result;
 
-        /* VCC5V is connected to channel 2 */
+	/* VCC5V is connected to channel 2 */
 
-        if ((result = adc_read (2)) == -1) {
-                printf ("%s: VCC5V could not be read\n", __FUNCTION__);
-                return (-1);
-        }
-        /*
-         * Calculate voltage value. Split in two parts because there is no
-         * floating point support.  VCC5V is connected over an resistor divider:
-         * VCC5V=ADCval*2,5V/1023*(10K+30K)/10K.
-         */
-        result = result * 10 * 1000 / 1023; /* result in mV */
+	if ((result = adc_read (2)) == -1) {
+		printf ("%s: VCC5V could not be read\n", __FUNCTION__);
+		return (-1);
+	}
+	/*
+	 * Calculate voltage value. Split in two parts because there is no
+	 * floating point support.  VCC5V is connected over an resistor divider:
+	 * VCC5V=ADCval*2,5V/1023*(10K+30K)/10K.
+	 */
+	result = result * 10 * 1000 / 1023; /* result in mV */
 
-        return (result);
+	return (result);
 }
 
 
 static int test_dip (void)
 {
-        static int first_run = 1;
-        static int first_dip;
+	static int first_run = 1;
+	static int first_dip;
 
-        if (first_run) {
-                if ((first_dip = read_dip ()) == -1) {
-                        return (1);
-                }
-                first_run = 0;
-                debug ("%s: first_dip=%d\n", __FUNCTION__, first_dip);
-        }
-        if (first_dip != read_dip ()) {
-                return (1);
-        } else {
-                return (0);
-        }
+	if (first_run) {
+		if ((first_dip = read_dip ()) == -1) {
+			return (1);
+		}
+		first_run = 0;
+		debug ("%s: first_dip=%d\n", __FUNCTION__, first_dip);
+	}
+	if (first_dip != read_dip ()) {
+		return (1);
+	} else {
+		return (0);
+	}
 }
 
 
 static int test_vcc5v (void)
 {
-        int vcc5v;
+	int vcc5v;
 
-        if ((vcc5v = read_vcc5v ()) == -1) {
-                return (1);
-        }
+	if ((vcc5v = read_vcc5v ()) == -1) {
+		return (1);
+	}
 
-        if ((vcc5v > VCC5V_MAX) || (vcc5v < VCC5V_MIN)) {
-                return (1);
-        } else {
-                return (0);
-        }
+	if ((vcc5v > VCC5V_MAX) || (vcc5v < VCC5V_MIN)) {
+		printf ("%s: vcc5v[V/100]=%d\n", __FUNCTION__, vcc5v);
+		return (1);
+	} else {
+		return (0);
+	}
 }
 
 
 static int test_rotary_switch (void)
 {
-        static int first_run = 1;
-        static int first_rs;
+	static int first_run = 1;
+	static int first_rs;
 
-        if (first_run) {
-                /*
-                 * clear bits in CPLD, because they have random values after
-                 * power-up or reset.
-                 */
-                *CPLD_ROTARY_SWITCH |= (1 << 16) | (1 << 17);
+	if (first_run) {
+		/*
+		 * clear bits in CPLD, because they have random values after
+		 * power-up or reset.
+		 */
+		*CPLD_ROTARY_SWITCH |= (1 << 16) | (1 << 17);
 
-                first_rs = ((*CPLD_ROTARY_SWITCH >> 16) & 0x7);
-                first_run = 0;
-                debug ("%s: first_rs=%d\n", __FUNCTION__, first_rs);
-        }
+		first_rs = ((*CPLD_ROTARY_SWITCH >> 16) & 0x7);
+		first_run = 0;
+		debug ("%s: first_rs=%d\n", __FUNCTION__, first_rs);
+	}
 
-        if (first_rs != ((*CPLD_ROTARY_SWITCH >> 16) & 0x7)) {
-                return (1);
-        } else {
-                return (0);
-        }
+	if (first_rs != ((*CPLD_ROTARY_SWITCH >> 16) & 0x7)) {
+		return (1);
+	} else {
+		return (0);
+	}
 }
 
 
 static int test_sram (void)
 {
-        return (memory_post_tests (SRAM_ADDR, SRAM_SIZE));
+	return (memory_post_tests (SRAM_ADDR, SRAM_SIZE));
 }
 
 
 static int test_eeprom (void)
 {
-        unsigned char temp[sizeof (EEPROM_TEST_STRING_1)];
-        int result = 0;
+	unsigned char temp[sizeof (EEPROM_TEST_STRING_1)];
+	int result = 0;
 
-        /* write test string 1, read back and verify */
-        if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
-                                EEPROM_TEST_STRING_1,
-                                sizeof (EEPROM_TEST_STRING_1))) {
-                return (1);
-        }
+	/* write test string 1, read back and verify */
+	if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
+				EEPROM_TEST_STRING_1,
+				sizeof (EEPROM_TEST_STRING_1))) {
+		return (1);
+	}
 
-        if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
-                               temp, sizeof (EEPROM_TEST_STRING_1))) {
-                return (1);
-        }
+	if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
+			       temp, sizeof (EEPROM_TEST_STRING_1))) {
+		return (1);
+	}
 
-        if (strcmp (temp, EEPROM_TEST_STRING_1) != 0) {
-                result = 1;
-                printf ("%s: error; read_str = \"%s\"\n", __FUNCTION__, temp);
-        }
+	if (strcmp (temp, EEPROM_TEST_STRING_1) != 0) {
+		result = 1;
+		printf ("%s: error; read_str = \"%s\"\n", __FUNCTION__, temp);
+	}
 
-        /* write test string 2, read back and verify */
-        if (result == 0) {
-                if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
-                                        EEPROM_TEST_STRING_2,
-                                        sizeof (EEPROM_TEST_STRING_2))) {
-                        return (1);
-                }
+	/* write test string 2, read back and verify */
+	if (result == 0) {
+		if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
+					EEPROM_TEST_STRING_2,
+					sizeof (EEPROM_TEST_STRING_2))) {
+			return (1);
+		}
 
-                if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
-                                       temp, sizeof (EEPROM_TEST_STRING_2))) {
-                        return (1);
-                }
+		if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
+				       temp, sizeof (EEPROM_TEST_STRING_2))) {
+			return (1);
+		}
 
-                if (strcmp (temp, EEPROM_TEST_STRING_2) != 0) {
-                        result = 1;
-                        printf ("%s: error; read str = \"%s\"\n",
-                                __FUNCTION__, temp);
-                }
-        }
-        return (result);
+		if (strcmp (temp, EEPROM_TEST_STRING_2) != 0) {
+			result = 1;
+			printf ("%s: error; read str = \"%s\"\n",
+				__FUNCTION__, temp);
+		}
+	}
+	return (result);
 }
 
 
 static int test_contact_temp (void)
 {
-        int contact_temp;
+	int contact_temp;
 
-        spi_init ();
-        contact_temp = tsc2000_contact_temp ();
+	spi_init ();
+	contact_temp = tsc2000_contact_temp ();
 
-        if ((contact_temp < MIN_CONTACT_TEMP)
-            || (contact_temp > MAX_CONTACT_TEMP))
-                return (1);
-        else
-                return (0);
+	if ((contact_temp < MIN_CONTACT_TEMP)
+	    || (contact_temp > MAX_CONTACT_TEMP))
+		return (1);
+	else
+		return (0);
 }
 
 
 int i2c_write_multiple (uchar chip, uint addr, int alen,
 			uchar *buffer, int len)
 {
-        int i;
+	int i;
 
-        if (alen != 1) {
-                printf ("%s: addr len other than 1 not supported\n",
-                         __FUNCTION__);
-                return (1);
-        }
+	if (alen != 1) {
+		printf ("%s: addr len other than 1 not supported\n",
+			 __FUNCTION__);
+		return (1);
+	}
 
-        for (i = 0; i < len; i++) {
-                if (i2c_write (chip, addr+i, alen, buffer+i, 1)) {
-                        printf ("%s: could not write to i2c device %d"
-                                 ", addr %d\n", __FUNCTION__, chip, addr);
-                        return (1);
-                }
+	for (i = 0; i < len; i++) {
+		if (i2c_write (chip, addr+i, alen, buffer+i, 1)) {
+			printf ("%s: could not write to i2c device %d"
+				 ", addr %d\n", __FUNCTION__, chip, addr);
+			return (1);
+		}
 #if 0
-                printf ("chip=%#x, addr+i=%#x+%d=%p, alen=%d, *buffer+i="
-                        "%#x+%d=%p=\"%.1s\"\n", chip, addr, i, addr+i,
-                        alen, buffer, i, buffer+i, buffer+i);
+		printf ("chip=%#x, addr+i=%#x+%d=%p, alen=%d, *buffer+i="
+			"%#x+%d=%p=\"%.1s\"\n", chip, addr, i, addr+i,
+			alen, buffer, i, buffer+i, buffer+i);
 #endif
 
-                udelay (30000);
-        }
-        return (0);
+		udelay (30000);
+	}
+	return (0);
 }
 
 
 int i2c_read_multiple ( uchar chip, uint addr, int alen,
 			uchar *buffer, int len)
 {
-        int i;
+	int i;
 
-        if (alen != 1) {
-                printf ("%s: addr len other than 1 not supported\n",
-                         __FUNCTION__);
-                return (1);
-        }
+	if (alen != 1) {
+		printf ("%s: addr len other than 1 not supported\n",
+			 __FUNCTION__);
+		return (1);
+	}
 
-        for (i = 0; i < len; i++) {
-                if (i2c_read (chip, addr+i, alen, buffer+i, 1)) {
-                        printf ("%s: could not read from i2c device %#x"
-                                 ", addr %d\n", __FUNCTION__, chip, addr);
-                        return (1);
-                }
-        }
-        return (0);
+	for (i = 0; i < len; i++) {
+		if (i2c_read (chip, addr+i, alen, buffer+i, 1)) {
+			printf ("%s: could not read from i2c device %#x"
+				 ", addr %d\n", __FUNCTION__, chip, addr);
+			return (1);
+		}
+	}
+	return (0);
 }
 
 
 static int adc_read (unsigned int channel)
 {
-        int j = 1000; /* timeout value for wait loop in us */
-        S3C2400_ADC *padc;
+	int j = 1000; /* timeout value for wait loop in us */
+	int result;
+	S3C2400_ADC *padc;
 
-        padc = S3C2400_GetBase_ADC();
-        channel &= 0x7;
+	padc = S3C2400_GetBase_ADC();
+	channel &= 0x7;
 
-        adc_init ();
+	adc_init ();
 
-	debug ("%s: adccon %#x\n", __FUNCTION__, padc->ADCCON);
-
-        padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
+	padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
 	padc->ADCCON &= ~(0x7 << 3); /* clear the channel bits */
-        padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);
+	padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);
 
-        debug ("%s: reading ch %d, addcon %#x\n", __FUNCTION__,
-		(padc->ADCCON >> 3) & 0x7, padc->ADCCON);
+	while (j--) {
+		if ((padc->ADCCON & ADC_ENABLE_START) == 0)
+			break;
+		udelay (1);
+	}
 
-        while (j--) {
-                if ((padc->ADCCON & ADC_ENABLE_START) == 0)
-                        break;
-                udelay (1);
-        }
+	if (j == 0) {
+		printf("%s: ADC timeout\n", __FUNCTION__);
+		padc->ADCCON |= ADC_STDBM; /* select standby mode */
+		return -1;
+	}
 
-        if (j == 0) {
-                printf("%s: ADC timeout\n", __FUNCTION__);
-                padc->ADCCON |= ADC_STDBM; /* select standby mode */
-                return -1;
-        }
+	result = padc->ADCDAT & 0x3FF;
 
-        padc->ADCCON |= ADC_STDBM; /* select standby mode */
+	padc->ADCCON |= ADC_STDBM; /* select standby mode */
 
-        debug ("%s: return %#x, adccon %#x\n", __FUNCTION__,
-		padc->ADCDAT & 0x3FF, padc->ADCCON);
+	debug ("%s: channel %d, result[DIGIT]=%d\n", __FUNCTION__,
+	       (padc->ADCCON >> 3) & 0x7, result);
 
-        return (padc->ADCDAT & 0x3FF);
+	/*
+	 * Wait for ADC to be ready for next conversion. This delay value was
+	 * estimated, because the datasheet does not specify a value.
+	 */
+	udelay (1000);
+
+	return (result);
 }
 
 
 static void adc_init (void)
 {
-        S3C2400_ADC *padc;
+	S3C2400_ADC *padc;
 
-        padc = S3C2400_GetBase_ADC();
+	padc = S3C2400_GetBase_ADC();
 
 	padc->ADCCON &= ~(0xff << 6); /* clear prescaler bits */
 	padc->ADCCON |= ((65 << 6) | ADC_PRSCEN); /* set prescaler */
 
-        return;
+	/*
+	 * Wait some time to avoid problem with very first call of
+	 * adc_read(). Without this delay, sometimes the first read
+	 * adc value is 0. Perhaps because the adjustment of prescaler
+	 * takes some clock cycles?
+	 */
+	udelay (1000);
+
+	return;
 }
 
 
 static void led_set (unsigned int state)
 {
-        S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 
-        led_init ();
+	led_init ();
 
-        switch (state) {
-        case 0: /* turn LED off */
-                gpio->PADAT |= (1 << 12);
-                break;
-        case 1: /* turn LED on */
-                gpio->PADAT &= ~(1 << 12);
-                break;
-        default:
-        }
+	switch (state) {
+	case 0: /* turn LED off */
+		gpio->PADAT |= (1 << 12);
+		break;
+	case 1: /* turn LED on */
+		gpio->PADAT &= ~(1 << 12);
+		break;
+	default:
+	}
 }
 
 static void led_blink (void)
 {
-        led_init ();
+	led_init ();
 
-        /* blink LED. This function does not return! */
-        while (1) {
-                led_set (1);
-                udelay (1000000 / LED_BLINK_FREQ / 2);
-                led_set (0);
-                udelay (1000000 / LED_BLINK_FREQ / 2);
-        }
+	/* blink LED. This function does not return! */
+	while (1) {
+		led_set (1);
+		udelay (1000000 / LED_BLINK_FREQ / 2);
+		led_set (0);
+		udelay (1000000 / LED_BLINK_FREQ / 2);
+	}
 }
 
 
 static void led_init (void)
 {
-        S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 
-        /* configure GPA12 as output and set to High -> LED off */
-        gpio->PACON &= ~(1 << 12);
-        gpio->PADAT |= (1 << 12);
+	/* configure GPA12 as output and set to High -> LED off */
+	gpio->PACON &= ~(1 << 12);
+	gpio->PADAT |= (1 << 12);
 }
 
 
 static void sdelay (unsigned long seconds)
 {
-        unsigned long i;
+	unsigned long i;
 
-        for (i = 0; i < seconds; i++) {
-                udelay (1000000);
-        }
+	for (i = 0; i < seconds; i++) {
+		udelay (1000000);
+	}
 }
 
 
 static int global_vars_write_to_eeprom (void)
 {
-        if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_STATUS, 1,
-                                (unsigned char*) &status, 1)) {
-                return (1);
-        }
-        if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_PASS_CYCLES, 1,
-                                (unsigned char*) &pass_cycles, 2)) {
-                return (1);
-        }
-        if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_CYCLE,
-                                1, (unsigned char*) &first_error_cycle, 2)) {
-                return (1);
-        }
-        if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NUM,
-                                1, (unsigned char*) &first_error_num, 1)) {
-                return (1);
-        }
-        if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NAME,
-                                1, first_error_name,
-                                sizeof(first_error_name))) {
-                return (1);
-        }
-        return (0);
+	if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_STATUS, 1,
+				(unsigned char*) &status, 1)) {
+		return (1);
+	}
+	if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_PASS_CYCLES, 1,
+				(unsigned char*) &pass_cycles, 2)) {
+		return (1);
+	}
+	if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_CYCLE,
+				1, (unsigned char*) &first_error_cycle, 2)) {
+		return (1);
+	}
+	if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NUM,
+				1, (unsigned char*) &first_error_num, 1)) {
+		return (1);
+	}
+	if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NAME,
+				1, first_error_name,
+				sizeof(first_error_name))) {
+		return (1);
+	}
+	return (0);
 }
 
 static void global_vars_init (void)
 {
-        status                  = 1; /* error */
-        pass_cycles             = 0;
-        first_error_cycle       = 0;
-        first_error_num         = 0;
-        first_error_name[0]     = '\0';
-        act_cycle               = 0;
-        max_cycles              = 0;
+	status                  = 1; /* error */
+	pass_cycles             = 0;
+	first_error_cycle       = 0;
+	first_error_num         = 0;
+	first_error_name[0]     = '\0';
+	act_cycle               = 0;
+	max_cycles              = 0;
 }
 
 
 static void test_function_table_init (void)
 {
-        int i;
+	int i;
 
-  	for (i = 0; i < BIF_MAX; i++)
+	for (i = 0; i < BIF_MAX; i++)
 		test_function[i].pf = dummy;
 
-        /*
-         * the length of "name" must not exceed 16, including the '\0'
-         * termination. See also the EEPROM address map.
-         */
-        test_function[0].pf = test_dip;
-        test_function[0].name = "dip";
+	/*
+	 * the length of "name" must not exceed 16, including the '\0'
+	 * termination. See also the EEPROM address map.
+	 */
+	test_function[0].pf = test_dip;
+	test_function[0].name = "dip";
 
-        test_function[1].pf = test_vcc5v;
-        test_function[1].name = "vcc5v";
+	test_function[1].pf = test_vcc5v;
+	test_function[1].name = "vcc5v";
 
-        test_function[2].pf = test_rotary_switch;
-        test_function[2].name = "rotary_switch";
+	test_function[2].pf = test_rotary_switch;
+	test_function[2].name = "rotary_switch";
 
-        test_function[3].pf = test_sram;
-        test_function[3].name = "sram";
+	test_function[3].pf = test_sram;
+	test_function[3].name = "sram";
 
-        test_function[4].pf = test_eeprom;
-        test_function[4].name = "eeprom";
+	test_function[4].pf = test_eeprom;
+	test_function[4].name = "eeprom";
 
-        test_function[5].pf = test_contact_temp;
-        test_function[5].name = "contact_temp";
+	test_function[5].pf = test_contact_temp;
+	test_function[5].name = "contact_temp";
 }
 
 
 static int read_max_cycles (void)
 {
-        if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_MAX_CYCLES, 1,
-                               (unsigned char *) &max_cycles, 2) != 0) {
-                return (1);
-        }
+	if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_MAX_CYCLES, 1,
+			       (unsigned char *) &max_cycles, 2) != 0) {
+		return (1);
+	}
 
-        return (0);
+	return (0);
 }
 
 static int dummy(void)
 {
-        return (0);
+	return (0);
 }
 
 #endif	/* CFG_CMD_BSP */
diff --git a/board/trab/rs485.c b/board/trab/rs485.c
index 774fd59..2aedd2d 100644
--- a/board/trab/rs485.c
+++ b/board/trab/rs485.c
@@ -47,8 +47,8 @@
 	unsigned int reg = 0;
 
 	/* value is calculated so : (int)(PCLK/16./baudrate) -1 */
-        /* reg = (33000000 / (16 * gd->baudrate)) - 1; */
-        reg = (33000000 / (16 * 38.400)) - 1;
+	/* reg = (33000000 / (16 * gd->baudrate)) - 1; */
+	reg = (33000000 / (16 * 38400)) - 1;
 
 	/* FIFO enable, Tx/Rx FIFO clear */
 	uart->UFCON = 0x07;
@@ -67,18 +67,18 @@
 
 static void rs485_cfgio (void)
 {
-        S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 
-        gpio->PFCON &= ~(0x3 << 2);
-        gpio->PFCON |=  (0x2 << 2); /* configure GPF1 as RXD1 */
+	gpio->PFCON &= ~(0x3 << 2);
+	gpio->PFCON |=  (0x2 << 2); /* configure GPF1 as RXD1 */
 
-        gpio->PFCON &= ~(0x3 << 6);
-        gpio->PFCON |=  (0x2 << 6); /* configure GPF3 as TXD1 */
+	gpio->PFCON &= ~(0x3 << 6);
+	gpio->PFCON |=  (0x2 << 6); /* configure GPF3 as TXD1 */
 
-        gpio->PFUP |= (1 << 1); /* disable pullup on GPF1 */
-        gpio->PFUP |= (1 << 3); /* disable pullup on GPF3 */
+	gpio->PFUP |= (1 << 1); /* disable pullup on GPF1 */
+	gpio->PFUP |= (1 << 3); /* disable pullup on GPF3 */
 
-        gpio->PACON &= ~(1 << 11); /* set GPA11 (RS485_DE) to output */
+	gpio->PACON &= ~(1 << 11); /* set GPA11 (RS485_DE) to output */
 }
 
 /*
@@ -88,8 +88,8 @@
  */
 int rs485_init (void)
 {
-        rs485_cfgio ();
-        rs485_setbrg ();
+	rs485_cfgio ();
+	rs485_setbrg ();
 
 	return (0);
 }
@@ -168,13 +168,13 @@
 
 static void set_rs485de(unsigned char rs485de_state)
 {
-        S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 
-        /* This is on PORT A bit 11 */
-        if(rs485de_state)
-                gpio->PADAT |= (1 << 11);
-        else
-                gpio->PADAT &= ~(1 << 11);
+	/* This is on PORT A bit 11 */
+	if(rs485de_state)
+		gpio->PADAT |= (1 << 11);
+	else
+		gpio->PADAT &= ~(1 << 11);
 }
 
 
diff --git a/board/trab/trab_fkt.c b/board/trab/trab_fkt.c
index c147353..5613281 100644
--- a/board/trab/trab_fkt.c
+++ b/board/trab/trab_fkt.c
@@ -29,6 +29,19 @@
 #include "tsc2000.h"
 #include "rs485.h"
 
+/*
+ * define, to wait for the touch to be pressed, before reading coordinates in
+ * command do_touch. If not defined, an error message is printed, when the
+ * command do_touch is invoked and the touch is not pressed within an specific
+ * interval.
+ */
+#undef  CONFIG_TOUCH_WAIT_PRESSED 1
+
+/* max time to wait for touch is pressed */
+#ifndef CONFIG_TOUCH_WAIT_PRESSED
+#define TOUCH_TIMEOUT   5
+#endif /* !CONFIG_TOUCH_WAIT_PRESSED */
+
 /* assignment of CPU internal ADC channels with TRAB hardware */
 #define VCC5V   2
 #define VCC12V  3
@@ -51,7 +64,6 @@
 
 #define PCLK		66000000
 #define BUZZER_FREQ     1000    /* frequency in Hz */
-#define BUZZER_TIME     1000000 /* time in us */
 #define PWM_FREQ        500
 
 
@@ -62,7 +74,7 @@
 #define CALIB_TL 0              /* calibration point in (T)op (L)eft corner */
 #define CALIB_DR 1              /* calibration point in (D)own (R)ight corner */
 
-/* EEPROM addresse map */
+/* EEPROM address map */
 #define SERIAL_NUMBER           8
 #define TOUCH_X0                52
 #define TOUCH_Y0                54
@@ -102,7 +114,7 @@
 int do_pressure (void);
 int do_v_bat (void);
 int do_vfd_id (void);
-int do_buzzer (void);
+int do_buzzer (char **);
 int do_led (char **);
 int do_full_bridge (char **);
 int do_dac (char **);
@@ -114,19 +126,36 @@
 int do_rs485 (char **);
 int do_serial_number (char **);
 int do_crc16 (void);
+int do_power_switch (void);
+int do_gain (char **);
+int do_eeprom (char **);
 
 /* helper functions */
 static void adc_init (void);
 static int adc_read (unsigned int channel);
 static void print_identifier (void);
+
+#ifdef CONFIG_TOUCH_WAIT_PRESSED
 static void touch_wait_pressed (void);
+#else
+static int touch_check_pressed (void);
+#endif /* CONFIG_TOUCH_WAIT_PRESSED */
+
 static void touch_read_x_y (int *x, int *y);
 static int touch_write_clibration_values (int calib_point, int x, int y);
 static int rs485_send_line (const char *data);
 static int rs485_receive_chars (char *data, int timeout);
 static unsigned short updcrc(unsigned short icrc, unsigned char *icp,
-                             unsigned int icnt);
+			     unsigned int icnt);
 
+#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+static int trab_eeprom_read (char **argv);
+static int trab_eeprom_write (char **argv);
+int i2c_write_multiple (uchar chip, uint addr, int alen, uchar *buffer,
+			int len);
+int i2c_read_multiple ( uchar chip, uint addr, int alen, uchar *buffer,
+			int len);
+#endif /* CFG_CMD_I2C */
 
 /*
  * TRAB board specific commands. Especially commands for burn-in and function
@@ -135,24 +164,24 @@
 
 int trab_fkt (int argc, char *argv[])
 {
-        int i;
+	int i;
 
-        app_startup(argv);
-        if (get_version () != XF_VERSION) {
-                printf ("Wrong XF_VERSION. Please re-compile with actual "
-                        "u-boot sources\n");
-                printf ("Example expects ABI version %d\n", XF_VERSION);
-                printf ("Actual U-Boot ABI version %d\n", (int)get_version());
-                return 1;
-        }
+	app_startup(argv);
+	if (get_version () != XF_VERSION) {
+		printf ("Wrong XF_VERSION. Please re-compile with actual "
+			"u-boot sources\n");
+		printf ("Example expects ABI version %d\n", XF_VERSION);
+		printf ("Actual U-Boot ABI version %d\n", (int)get_version());
+		return 1;
+	}
 
-        debug ("argc = %d\n", argc);
+	debug ("argc = %d\n", argc);
 
 	for (i=0; i<=argc; ++i) {
 		debug ("argv[%d] = \"%s\"\n", i, argv[i] ? argv[i] : "<NULL>");
-        }
+	}
 
-        adc_init ();
+	adc_init ();
 
 	switch (argc) {
 
@@ -162,103 +191,121 @@
 
 	case 2:
 		if (strcmp (argv[1], "info") == 0) {
-                        return (do_info ());
+			return (do_info ());
 		}
-                if (strcmp (argv[1], "dip") == 0) {
-                        return (do_dip ());
-                }
-                if (strcmp (argv[1], "vcc5v") == 0) {
-                        return (do_vcc5v ());
-                }
-                if (strcmp (argv[1], "vcc12v") == 0) {
-                        return (do_vcc12v ());
-                }
-                if (strcmp (argv[1], "buttons") == 0) {
-                        return (do_buttons ());
-                }
-                if (strcmp (argv[1], "fill_level") == 0) {
-                        return (do_fill_level ());
-                }
-                if (strcmp (argv[1], "rotary_switch") == 0) {
-                        return (do_rotary_switch ());
-                }
-                if (strcmp (argv[1], "pressure") == 0) {
-                        return (do_pressure ());
-                }
-                if (strcmp (argv[1], "v_bat") == 0) {
-                        return (do_v_bat ());
-                }
-                if (strcmp (argv[1], "vfd_id") == 0) {
-                        return (do_vfd_id ());
-                }
-                if (strcmp (argv[1], "buzzer") == 0) {
-                        return (do_buzzer ());
-                }
-                if (strcmp (argv[1], "motor_contact") == 0) {
-                        return (do_motor_contact ());
-                }
-                if (strcmp (argv[1], "crc16") == 0) {
-                        return (do_crc16 ());
-                }
-                break;
+		if (strcmp (argv[1], "dip") == 0) {
+			return (do_dip ());
+		}
+		if (strcmp (argv[1], "vcc5v") == 0) {
+			return (do_vcc5v ());
+		}
+		if (strcmp (argv[1], "vcc12v") == 0) {
+			return (do_vcc12v ());
+		}
+		if (strcmp (argv[1], "buttons") == 0) {
+			return (do_buttons ());
+		}
+		if (strcmp (argv[1], "fill_level") == 0) {
+			return (do_fill_level ());
+		}
+		if (strcmp (argv[1], "rotary_switch") == 0) {
+			return (do_rotary_switch ());
+		}
+		if (strcmp (argv[1], "pressure") == 0) {
+			return (do_pressure ());
+		}
+		if (strcmp (argv[1], "v_bat") == 0) {
+			return (do_v_bat ());
+		}
+		if (strcmp (argv[1], "vfd_id") == 0) {
+			return (do_vfd_id ());
+		}
+		if (strcmp (argv[1], "motor_contact") == 0) {
+			return (do_motor_contact ());
+		}
+		if (strcmp (argv[1], "crc16") == 0) {
+			return (do_crc16 ());
+		}
+		if (strcmp (argv[1], "power_switch") == 0) {
+			return (do_power_switch ());
+		}
+		break;
 
 	case 3:
-                if (strcmp (argv[1], "full_bridge") == 0) {
-                        return (do_full_bridge (argv));
-                }
-                if (strcmp (argv[1], "dac") == 0) {
-                        return (do_dac (argv));
-                }
-                if (strcmp (argv[1], "motor") == 0) {
-                        return (do_motor (argv));
-                }
-                if (strcmp (argv[1], "pwm") == 0) {
-                        return (do_pwm (argv));
-                }
-                if (strcmp (argv[1], "thermo") == 0) {
-                        return (do_thermo (argv));
-                }
-                if (strcmp (argv[1], "touch") == 0) {
-                        return (do_touch (argv));
-                }
-                if (strcmp (argv[1], "serial_number") == 0) {
-                        return (do_serial_number (argv));
-                }
-                break;
+		if (strcmp (argv[1], "full_bridge") == 0) {
+			return (do_full_bridge (argv));
+		}
+		if (strcmp (argv[1], "dac") == 0) {
+			return (do_dac (argv));
+		}
+		if (strcmp (argv[1], "motor") == 0) {
+			return (do_motor (argv));
+		}
+		if (strcmp (argv[1], "pwm") == 0) {
+			return (do_pwm (argv));
+		}
+		if (strcmp (argv[1], "thermo") == 0) {
+			return (do_thermo (argv));
+		}
+		if (strcmp (argv[1], "touch") == 0) {
+			return (do_touch (argv));
+		}
+		if (strcmp (argv[1], "serial_number") == 0) {
+			return (do_serial_number (argv));
+		}
+		if (strcmp (argv[1], "buzzer") == 0) {
+			return (do_buzzer (argv));
+		}
+		if (strcmp (argv[1], "gain") == 0) {
+			return (do_gain (argv));
+		}
+		break;
 
-        case 4:
-                if (strcmp (argv[1], "led") == 0) {
-                        return (do_led (argv));
-                }
-                if (strcmp (argv[1], "rs485") == 0) {
-                        return (do_rs485 (argv));
-                }
-                if (strcmp (argv[1], "serial_number") == 0) {
-                        return (do_serial_number (argv));
-                }
-                break;
+	case 4:
+		if (strcmp (argv[1], "led") == 0) {
+			return (do_led (argv));
+		}
+		if (strcmp (argv[1], "rs485") == 0) {
+			return (do_rs485 (argv));
+		}
+		if (strcmp (argv[1], "serial_number") == 0) {
+			return (do_serial_number (argv));
+		}
+		break;
+
+	case 5:
+		if (strcmp (argv[1], "eeprom") == 0) {
+			return (do_eeprom (argv));
+		}
+		break;
+
+	case 6:
+		if (strcmp (argv[1], "eeprom") == 0) {
+			return (do_eeprom (argv));
+		}
+		break;
 
 	default:
 		break;
 	}
 
 	printf ("Usage:\n<command> <parameter1> <parameter2> ...\n");
-        return 1;
+	return 1;
 }
 
 int do_info (void)
 {
-        printf ("Stand-alone application for TRAB board function test\n");
-        printf ("Built: %s at %s\n", __DATE__ , __TIME__ );
+	printf ("Stand-alone application for TRAB board function test\n");
+	printf ("Built: %s at %s\n", __DATE__ , __TIME__ );
 
 	return 0;
 }
 
 int do_dip (void)
 {
-        unsigned int result = 0;
-        int adc_val;
-        int i;
+	unsigned int result = 0;
+	int adc_val;
+	int i;
 
 	/***********************************************************
 	 DIP switch connection (according to wa4-cpu.sp.301.pdf, page 3):
@@ -273,10 +320,10 @@
 
 	for (i = 7; i > 3; i--) {
 
-                if ((adc_val = adc_read (i)) == -1) {
-                        printf ("Channel %d could not be read\n", i);
-                        return 1;
-                }
+		if ((adc_val = adc_read (i)) == -1) {
+			printf ("Channel %d could not be read\n", i);
+			return 1;
+		}
 
 		/*
 		 * Input voltage (switch open) is 1.8 V.
@@ -284,18 +331,18 @@
 		 * Set trigger at halve that value.
 		 */
 		if (adc_val < 368)
-                        result |= (1 << (i-4));
-        }
+			result |= (1 << (i-4));
+	}
 
-        /* print result to console */
-        print_identifier ();
-        for (i = 0; i < 4; i++) {
-                if ((result & (1 << i)) == 0)
-                        printf("0");
-                else
-                        printf("1");
-        }
-        printf("\n");
+	/* print result to console */
+	print_identifier ();
+	for (i = 0; i < 4; i++) {
+		if ((result & (1 << i)) == 0)
+			printf("0");
+		else
+			printf("1");
+	}
+	printf("\n");
 
 	return 0;
 }
@@ -303,25 +350,25 @@
 
 int do_vcc5v (void)
 {
-        int result;
+	int result;
 
-        /* VCC5V is connected to channel 2 */
+	/* VCC5V is connected to channel 2 */
 
-        if ((result = adc_read (VCC5V)) == -1) {
-                printf ("VCC5V could not be read\n");
-                return 1;
-        }
+	if ((result = adc_read (VCC5V)) == -1) {
+		printf ("VCC5V could not be read\n");
+		return 1;
+	}
 
-        /*
-         * Calculate voltage value. Split in two parts because there is no
-         * floating point support.  VCC5V is connected over an resistor divider:
-         * VCC5V=ADCval*2,5V/1023*(10K+30K)/10K.
-         */
-        print_identifier ();
-        printf ("%d", (result & 0x3FF)* 10 / 1023);
-        printf (".%d", ((result & 0x3FF)* 10 % 1023)* 10 / 1023);
-        printf ("%d V\n", (((result & 0x3FF) * 10 % 1023 ) * 10 % 1023)
-                * 10 / 1024);
+	/*
+	 * Calculate voltage value. Split in two parts because there is no
+	 * floating point support.  VCC5V is connected over an resistor divider:
+	 * VCC5V=ADCval*2,5V/1023*(10K+30K)/10K.
+	 */
+	print_identifier ();
+	printf ("%d", (result & 0x3FF)* 10 / 1023);
+	printf (".%d", ((result & 0x3FF)* 10 % 1023)* 10 / 1023);
+	printf ("%d V\n", (((result & 0x3FF) * 10 % 1023 ) * 10 % 1023)
+		* 10 / 1024);
 
 	return 0;
 }
@@ -329,299 +376,338 @@
 
 int do_vcc12v (void)
 {
-        int result;
+	int result;
 
-        if ((result = adc_read (VCC12V)) == -1) {
-                printf ("VCC12V could not be read\n");
-                return 1;
-        }
+	if ((result = adc_read (VCC12V)) == -1) {
+		printf ("VCC12V could not be read\n");
+		return 1;
+	}
 
-        /*
-         * Calculate voltage value. Split in two parts because there is no
-         * floating point support.  VCC5V is connected over an resistor divider:
-         * VCC12V=ADCval*2,5V/1023*(30K+270K)/30K.
-         */
-        print_identifier ();
-        printf ("%d", (result & 0x3FF)* 25 / 1023);
-        printf (".%d V\n", ((result & 0x3FF)* 25 % 1023) * 10 / 1023);
+	/*
+	 * Calculate voltage value. Split in two parts because there is no
+	 * floating point support.  VCC5V is connected over an resistor divider:
+	 * VCC12V=ADCval*2,5V/1023*(30K+270K)/30K.
+	 */
+	print_identifier ();
+	printf ("%d", (result & 0x3FF)* 25 / 1023);
+	printf (".%d V\n", ((result & 0x3FF)* 25 % 1023) * 10 / 1023);
 
-    	return 0;
+	return 0;
 }
 
 static int adc_read (unsigned int channel)
 {
-        int j = 1000; /* timeout value for wait loop in us */
-        S3C2400_ADC *padc;
+	int j = 1000; /* timeout value for wait loop in us */
+	int result;
+	S3C2400_ADC *padc;
 
-        padc = S3C2400_GetBase_ADC();
-        channel &= 0x7;
+	padc = S3C2400_GetBase_ADC();
+	channel &= 0x7;
 
-	debug ("%s: adccon %#x\n", __FUNCTION__, padc->ADCCON);
-
-        padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
+	padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
 	padc->ADCCON &= ~(0x7 << 3); /* clear the channel bits */
-        padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);
+	padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);
 
-        debug ("%s: reading ch %d, addcon %#x\n", __FUNCTION__,
-            (padc->ADCCON >> 3) & 0x7, padc->ADCCON);
+	while (j--) {
+		if ((padc->ADCCON & ADC_ENABLE_START) == 0)
+			break;
+		udelay (1);
+	}
 
-        while (j--) {
-                if ((padc->ADCCON & ADC_ENABLE_START) == 0)
-                        break;
-                udelay (1);
-        }
+	if (j == 0) {
+		printf("%s: ADC timeout\n", __FUNCTION__);
+		padc->ADCCON |= ADC_STDBM; /* select standby mode */
+		return -1;
+	}
 
-        if (j == 0) {
-                printf("%s: ADC timeout\n", __FUNCTION__);
-                padc->ADCCON |= ADC_STDBM; /* select standby mode */
-                return -1;
-        }
+	result = padc->ADCDAT & 0x3FF;
 
-        padc->ADCCON |= ADC_STDBM; /* select standby mode */
+	padc->ADCCON |= ADC_STDBM; /* select standby mode */
 
-        debug ("%s: return %#x, adccon %#x\n", __FUNCTION__, padc->ADCDAT & 0x3FF,
-            padc->ADCCON);
+	debug ("%s: channel %d, result[DIGIT]=%d\n", __FUNCTION__,
+	       (padc->ADCCON >> 3) & 0x7, result);
 
-        return (padc->ADCDAT & 0x3FF);
+	/*
+	 * Wait for ADC to be ready for next conversion. This delay value was
+	 * estimated, because the datasheet does not specify a value.
+	 */
+	udelay (1000);
+
+	return (result);
 }
 
 
 static void adc_init (void)
 {
-        S3C2400_ADC *padc;
+	S3C2400_ADC *padc;
 
-        padc = S3C2400_GetBase_ADC();
-
-	debug ("%s: adccon %#x\n", __FUNCTION__, padc->ADCCON);
+	padc = S3C2400_GetBase_ADC();
 
 	padc->ADCCON &= ~(0xff << 6); /* clear prescaler bits */
 	padc->ADCCON |= ((65 << 6) | ADC_PRSCEN); /* set prescaler */
 
-	debug ("%s: init completed: adccon %#x\n", __FUNCTION__, padc->ADCCON);
-        return;
+	/*
+	 * Wait some time to avoid problem with very first call of
+	 * adc_read(). Without * this delay, sometimes the first read adc
+	 * value is 0. Perhaps because the * adjustment of prescaler takes
+	 * some clock cycles?
+	 */
+	udelay (1000);
+
+	return;
 }
 
 
 int do_buttons (void)
 {
-        int result;
-        int i;
+	int result;
+	int i;
 
-        result = *CPLD_BUTTONS; /* read CPLD */
-        debug ("%s: cpld_taster (32 bit) %#x\n", __FUNCTION__, result);
+	result = *CPLD_BUTTONS; /* read CPLD */
+	debug ("%s: cpld_taster (32 bit) %#x\n", __FUNCTION__, result);
 
-        /* print result to console */
-        print_identifier ();
-        for (i = 16; i <= 19; i++) {
-                if ((result & (1 << i)) == 0)
-                        printf("0");
-                else
-                        printf("1");
-        }
-        printf("\n");
+	/* print result to console */
+	print_identifier ();
+	for (i = 16; i <= 19; i++) {
+		if ((result & (1 << i)) == 0)
+			printf("0");
+		else
+			printf("1");
+	}
+	printf("\n");
+	return 0;
+}
+
+
+int do_power_switch (void)
+{
+	int result;
+
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+	/* configure GPE7 as input */
+	gpio->PECON &= ~(0x3 << (2 * 7));
+
+	/* signal GPE7 from power switch is low active: 0=on , 1=off */
+	result = ((gpio->PEDAT & (1 << 7)) == (1 << 7)) ? 0 : 1;
+
+	print_identifier ();
+	printf("%d\n", result);
 	return 0;
 }
 
 
 int do_fill_level (void)
 {
-        int result;
+	int result;
 
-        result = *CPLD_FILL_LEVEL; /* read CPLD */
-        debug ("%s: cpld_fuellstand (32 bit) %#x\n", __FUNCTION__, result);
+	result = *CPLD_FILL_LEVEL; /* read CPLD */
+	debug ("%s: cpld_fuellstand (32 bit) %#x\n", __FUNCTION__, result);
 
-        /* print result to console */
-        print_identifier ();
-        if ((result & (1 << 16)) == 0)
-                printf("0\n");
-        else
-                printf("1\n");
+	/* print result to console */
+	print_identifier ();
+	if ((result & (1 << 16)) == 0)
+		printf("0\n");
+	else
+		printf("1\n");
 	return 0;
 }
 
 
 int do_rotary_switch (void)
 {
-        int result;
+	int result;
+	/*
+	 * Please note, that the default values of the direction bits are
+	 * undefined after reset. So it is a good idea, to make first a dummy
+	 * call to this function, to clear the direction bits and set so to
+	 * proper values.
+	 */
 
-        result = *CPLD_ROTARY_SWITCH; /* read CPLD */
-        debug ("%s: cpld_inc (32 bit) %#x\n", __FUNCTION__, result);
+	result = *CPLD_ROTARY_SWITCH; /* read CPLD */
+	debug ("%s: cpld_inc (32 bit) %#x\n", __FUNCTION__, result);
 
-        *CPLD_ROTARY_SWITCH |= (3 << 16); /* clear direction bits in CPLD */
+	*CPLD_ROTARY_SWITCH |= (3 << 16); /* clear direction bits in CPLD */
 
-        /* print result to console */
-        print_identifier ();
-        if ((result & (1 << 16)) == (1 << 16))
-                printf("R");
-        if ((result & (1 << 17)) == (1 << 17))
-                printf("L");
-        if (((result & (1 << 16)) == 0) && ((result & (1 << 17)) == 0))
-                printf("0");
-        if ((result & (1 << 18)) == 0)
-                printf("0\n");
-        else
-                printf("1\n");
+	/* print result to console */
+	print_identifier ();
+	if ((result & (1 << 16)) == (1 << 16))
+		printf("R");
+	if ((result & (1 << 17)) == (1 << 17))
+		printf("L");
+	if (((result & (1 << 16)) == 0) && ((result & (1 << 17)) == 0))
+		printf("0");
+	if ((result & (1 << 18)) == 0)
+		printf("0\n");
+	else
+		printf("1\n");
 	return 0;
 }
 
 
 int do_vfd_id (void)
 {
-        int i;
-        long int pcup_old, pccon_old;
-        int vfd_board_id;
-        S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	int i;
+	long int pcup_old, pccon_old;
+	int vfd_board_id;
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* try to red vfd board id from the value defined by pull-ups */
 
-        pcup_old = gpio->PCUP;
-        pccon_old = gpio->PCCON;
+	pcup_old = gpio->PCUP;
+	pccon_old = gpio->PCCON;
 
 	gpio->PCUP = (gpio->PCUP & 0xFFF0); /* activate  GPC0...GPC3 pull-ups */
 	gpio->PCCON = (gpio->PCCON & 0xFFFFFF00); /* configure GPC0...GPC3 as
-                                                   * inputs */
+						   * inputs */
 	udelay (10);            /* allow signals to settle */
 	vfd_board_id = (~gpio->PCDAT) & 0x000F;	/* read GPC0...GPC3 port pins */
 
-        gpio->PCCON = pccon_old;
-        gpio->PCUP = pcup_old;
+	gpio->PCCON = pccon_old;
+	gpio->PCUP = pcup_old;
 
-        /* print vfd_board_id to console */
-        print_identifier ();
-        for (i = 0; i < 4; i++) {
-                if ((vfd_board_id & (1 << i)) == 0)
-                        printf("0");
-                else
-                        printf("1");
-        }
-        printf("\n");
+	/* print vfd_board_id to console */
+	print_identifier ();
+	for (i = 0; i < 4; i++) {
+		if ((vfd_board_id & (1 << i)) == 0)
+			printf("0");
+		else
+			printf("1");
+	}
+	printf("\n");
 	return 0;
 }
 
-int do_buzzer (void)
+int do_buzzer (char **argv)
 {
-        int counter;
+	int counter;
 
 	S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
-        S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 
-        /* configure pin GPD7 as TOUT2 */
-	gpio->PDCON &= ~0xC000;
-	gpio->PDCON |= 0x8000;
-
-        /* set prescaler for timer 2, 3 and 4 */
-        timers->TCFG0 &= ~0xFF00;
+	/* set prescaler for timer 2, 3 and 4 */
+	timers->TCFG0 &= ~0xFF00;
 	timers->TCFG0 |=  0x0F00;
 
-        /* set divider for timer 2 */
+	/* set divider for timer 2 */
 	timers->TCFG1 &= ~0xF00;
 	timers->TCFG1 |=  0x300;
 
-        /* set frequency */
-        counter = (PCLK / BUZZER_FREQ) >> 9;
-        timers->ch[2].TCNTB = counter;
+	/* set frequency */
+	counter = (PCLK / BUZZER_FREQ) >> 9;
+	timers->ch[2].TCNTB = counter;
 	timers->ch[2].TCMPB = counter / 2;
 
-        debug ("%s: frequency: %d, duration: %d\n", __FUNCTION__, BUZZER_FREQ,
-            BUZZER_TIME);
+	if (strcmp (argv[2], "on") == 0) {
+		debug ("%s: frequency: %d\n", __FUNCTION__,
+		       BUZZER_FREQ);
 
-        /* start */
-	timers->TCON = (timers->TCON | UPDATE2 | RELOAD2) & ~INVERT2;
-	timers->TCON = (timers->TCON | START2) & ~UPDATE2;
+		/* configure pin GPD7 as TOUT2 */
+		gpio->PDCON &= ~0xC000;
+		gpio->PDCON |= 0x8000;
 
-        udelay (BUZZER_TIME);
+		/* start */
+		timers->TCON = (timers->TCON | UPDATE2 | RELOAD2) &
+				~INVERT2;
+		timers->TCON = (timers->TCON | START2) & ~UPDATE2;
+		return (0);
+	}
+	else if (strcmp (argv[2], "off") == 0) {
+		/* stop */
+		timers->TCON &= ~(START2 | RELOAD2);
 
-        /* stop */
-	timers->TCON &= ~(START2 | RELOAD2);
+		/* configure GPD7 as output and set to low */
+		gpio->PDCON &= ~0xC000;
+		gpio->PDCON |= 0x4000;
+		gpio->PDDAT &= ~0x80;
+		return (0);
+	}
 
-        /* port pin configuration */
-	gpio->PDCON &= ~0xC000;
-        gpio->PDCON |= 0x4000;
-        gpio->PDDAT &= ~0x80;
-	return 0;
+	printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+	return 1;
 }
 
 
 int do_led (char **argv)
 {
-        S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 
-        /* configure PC14 and PC15 as output */
-        gpio->PCCON &= ~(0xF << 28);
-        gpio->PCCON |= (0x5 << 28);
+	/* configure PC14 and PC15 as output */
+	gpio->PCCON &= ~(0xF << 28);
+	gpio->PCCON |= (0x5 << 28);
 
-        /* configure PD0 and PD4 as output */
-        gpio->PDCON &= ~((0x3 << 8) | 0x3);
-        gpio->PDCON |= ((0x1 << 8) | 0x1);
+	/* configure PD0 and PD4 as output */
+	gpio->PDCON &= ~((0x3 << 8) | 0x3);
+	gpio->PDCON |= ((0x1 << 8) | 0x1);
 
-        switch (simple_strtoul(argv[2], NULL, 10)) {
+	switch (simple_strtoul(argv[2], NULL, 10)) {
 
 	case 0:
 	case 1:
 		break;
 
-        case 2:
-                if (strcmp (argv[3], "on") == 0)
-                        gpio->PCDAT |= (1 << 14);
-                else
-                        gpio->PCDAT &= ~(1 << 14);
-                return 0;
+	case 2:
+		if (strcmp (argv[3], "on") == 0)
+			gpio->PCDAT |= (1 << 14);
+		else
+			gpio->PCDAT &= ~(1 << 14);
+		return 0;
 
-        case 3:
-                if (strcmp (argv[3], "on") == 0)
-                        gpio->PCDAT |= (1 << 15);
-                else
-                        gpio->PCDAT &= ~(1 << 15);
-                return 0;
+	case 3:
+		if (strcmp (argv[3], "on") == 0)
+			gpio->PCDAT |= (1 << 15);
+		else
+			gpio->PCDAT &= ~(1 << 15);
+		return 0;
 
-        case 4:
-                if (strcmp (argv[3], "on") == 0)
-                        gpio->PDDAT |= (1 << 0);
-                else
-                        gpio->PDDAT &= ~(1 << 0);
-                return 0;
+	case 4:
+		if (strcmp (argv[3], "on") == 0)
+			gpio->PDDAT |= (1 << 0);
+		else
+			gpio->PDDAT &= ~(1 << 0);
+		return 0;
 
-        case 5:
-                if (strcmp (argv[3], "on") == 0)
-                        gpio->PDDAT |= (1 << 4);
-                else
-                        gpio->PDDAT &= ~(1 << 4);
-                return 0;
+	case 5:
+		if (strcmp (argv[3], "on") == 0)
+			gpio->PDDAT |= (1 << 4);
+		else
+			gpio->PDDAT &= ~(1 << 4);
+		return 0;
 
-        default:
-                break;
+	default:
+		break;
 
-        }
-        printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
-        return 1;
+	}
+	printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+	return 1;
 }
 
 
 int do_full_bridge (char **argv)
 {
-        S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 
-        /* configure PD5 and PD6 as output */
-        gpio->PDCON &= ~((0x3 << 5*2) | (0x3 << 6*2));
-        gpio->PDCON |= ((0x1 << 5*2) | (0x1 << 6*2));
+	/* configure PD5 and PD6 as output */
+	gpio->PDCON &= ~((0x3 << 5*2) | (0x3 << 6*2));
+	gpio->PDCON |= ((0x1 << 5*2) | (0x1 << 6*2));
 
-        if (strcmp (argv[2], "+") == 0) {
-              gpio->PDDAT |= (1 << 5);
-              gpio->PDDAT |= (1 << 6);
-              return 0;
-        }
-        else if (strcmp (argv[2], "-") == 0) {
-                gpio->PDDAT &= ~(1 << 5);
-                gpio->PDDAT |= (1 << 6);
-                return 0;
-        }
-        else if (strcmp (argv[2], "off") == 0) {
-                gpio->PDDAT &= ~(1 << 5);
-                gpio->PDDAT &= ~(1 << 6);
-                return 0;
-        }
-        printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
-        return 1;
+	if (strcmp (argv[2], "+") == 0) {
+	      gpio->PDDAT |= (1 << 5);
+	      gpio->PDDAT |= (1 << 6);
+	      return 0;
+	}
+	else if (strcmp (argv[2], "-") == 0) {
+		gpio->PDDAT &= ~(1 << 5);
+		gpio->PDDAT |= (1 << 6);
+		return 0;
+	}
+	else if (strcmp (argv[2], "off") == 0) {
+		gpio->PDDAT &= ~(1 << 5);
+		gpio->PDDAT &= ~(1 << 6);
+		return 0;
+	}
+	printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+	return 1;
 }
 
 /* val must be in [0, 4095] */
@@ -633,77 +719,77 @@
 
 int do_dac (char **argv)
 {
-        int brightness;
+	int brightness;
 
-        /* initialize SPI */
-        spi_init ();
+	/* initialize SPI */
+	spi_init ();
 
-        if  (((brightness = simple_strtoul (argv[2], NULL, 10)) < 0) ||
-             (brightness > 255)) {
-                printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
-                return 1;
-        }
-        tsc2000_write(TSC2000_REG_DACCTL, 0x0); /* Power up DAC */
+	if  (((brightness = simple_strtoul (argv[2], NULL, 10)) < 0) ||
+	     (brightness > 255)) {
+		printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+		return 1;
+	}
+	tsc2000_write(TSC2000_REG_DACCTL, 0x0); /* Power up DAC */
 	tsc2000_write(TSC2000_REG_DAC, brightness & 0xff);
 
-        return 0;
+	return 0;
 }
 
 
 int do_v_bat (void)
 {
-        unsigned long ret, res;
+	unsigned long ret, res;
 
-        /* initialize SPI */
-        spi_init ();
+	/* initialize SPI */
+	spi_init ();
 
 	tsc2000_write(TSC2000_REG_ADC, 0x1836);
 
-        /* now wait for data available */
-        adc_wait_conversion_done();
+	/* now wait for data available */
+	adc_wait_conversion_done();
 
 	ret = tsc2000_read(TSC2000_REG_BAT1);
 	res = (tsc2000_to_uv(ret) + 1250) / 2500;
 	res += (ERROR_BATTERY * res) / 1000;
 
-        print_identifier ();
-        printf ("%ld", (res / 100));
-        printf (".%ld", ((res % 100) / 10));
-        printf ("%ld V\n", (res % 10));
+	print_identifier ();
+	printf ("%ld", (res / 100));
+	printf (".%ld", ((res % 100) / 10));
+	printf ("%ld V\n", (res % 10));
 	return 0;
 }
 
 
 int do_pressure (void)
 {
-        /* initialize SPI */
-        spi_init ();
+	/* initialize SPI */
+	spi_init ();
 
-        tsc2000_write(TSC2000_REG_ADC, 0x2436);
+	tsc2000_write(TSC2000_REG_ADC, 0x2436);
 
-        /* now wait for data available */
-        adc_wait_conversion_done();
+	/* now wait for data available */
+	adc_wait_conversion_done();
 
-        print_identifier ();
-        printf ("%d\n", tsc2000_read(TSC2000_REG_AUX2));
+	print_identifier ();
+	printf ("%d\n", tsc2000_read(TSC2000_REG_AUX2));
 	return 0;
 }
 
 
 int do_motor_contact (void)
 {
-        int result;
+	int result;
 
-        result = *CPLD_FILL_LEVEL; /* read CPLD */
-        debug ("%s: cpld_fuellstand (32 bit) %#x\n", __FUNCTION__, result);
+	result = *CPLD_FILL_LEVEL; /* read CPLD */
+	debug ("%s: cpld_fuellstand (32 bit) %#x\n", __FUNCTION__, result);
 
-        /* print result to console */
-        print_identifier ();
-        if ((result & (1 << 17)) == 0)
-                printf("0\n");
-        else
-                printf("1\n");
-        return 0;
+	/* print result to console */
+	print_identifier ();
+	if ((result & (1 << 17)) == 0)
+		printf("0\n");
+	else
+		printf("1\n");
+	return 0;
 }
 
 int do_motor (char **argv)
@@ -714,276 +800,341 @@
 	gpio->PGCON &= ~(0x3 << 0);
 	gpio->PGCON |= (0x1 << 0);
 
-        if (strcmp (argv[2], "on") == 0) {
-                gpio->PGDAT &= ~(1 << 0);
-                return 0;
-        }
-        if (strcmp (argv[2], "off") == 0) {
-                gpio->PGDAT |= (1 << 0);
-                return 0;
-        }
-        printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
-        return 1;
+	if (strcmp (argv[2], "on") == 0) {
+		gpio->PGDAT &= ~(1 << 0);
+		return 0;
+	}
+	if (strcmp (argv[2], "off") == 0) {
+		gpio->PGDAT |= (1 << 0);
+		return 0;
+	}
+	printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+	return 1;
 }
 
 static void print_identifier (void)
 {
-        printf ("## FKT: ");
+	printf ("## FKT: ");
 }
 
 int do_pwm (char **argv)
 {
-        int counter;
-        S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	int counter;
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 	S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
 
-        if (strcmp (argv[2], "on") == 0) {
-                /* configure pin GPD8 as TOUT3 */
-                gpio->PDCON &= ~(0x3 << 8*2);
-                gpio->PDCON |= (0x2 << 8*2);
+	if (strcmp (argv[2], "on") == 0) {
+		/* configure pin GPD8 as TOUT3 */
+		gpio->PDCON &= ~(0x3 << 8*2);
+		gpio->PDCON |= (0x2 << 8*2);
 
-                /* set prescaler for timer 2, 3 and 4 */
-                timers->TCFG0 &= ~0xFF00;
-                timers->TCFG0 |= 0x0F00;
+		/* set prescaler for timer 2, 3 and 4 */
+		timers->TCFG0 &= ~0xFF00;
+		timers->TCFG0 |= 0x0F00;
 
-                /* set divider for timer 3 */
-                timers->TCFG1 &= ~(0xf << 12);
-                timers->TCFG1 |= (0x3 << 12);
+		/* set divider for timer 3 */
+		timers->TCFG1 &= ~(0xf << 12);
+		timers->TCFG1 |= (0x3 << 12);
 
-                /* set frequency */
-                counter = (PCLK / PWM_FREQ) >> 9;
-                timers->ch[3].TCNTB = counter;
-                timers->ch[3].TCMPB = counter / 2;
+		/* set frequency */
+		counter = (PCLK / PWM_FREQ) >> 9;
+		timers->ch[3].TCNTB = counter;
+		timers->ch[3].TCMPB = counter / 2;
 
-                /* start timer */
-                timers->TCON = (timers->TCON | UPDATE3 | RELOAD3) & ~INVERT3;
-                timers->TCON = (timers->TCON | START3) & ~UPDATE3;
-                return 0;
-        }
-        if (strcmp (argv[2], "off") == 0) {
+		/* start timer */
+		timers->TCON = (timers->TCON | UPDATE3 | RELOAD3) & ~INVERT3;
+		timers->TCON = (timers->TCON | START3) & ~UPDATE3;
+		return 0;
+	}
+	if (strcmp (argv[2], "off") == 0) {
 
-                /* stop timer */
-                timers->TCON &= ~(START2 | RELOAD2);
+		/* stop timer */
+		timers->TCON &= ~(START2 | RELOAD2);
 
-                /* configure pin GPD8 as output and set to 0 */
-                gpio->PDCON &= ~(0x3 << 8*2);
-                gpio->PDCON |= (0x1 << 8*2);
-                gpio->PDDAT &= ~(1 << 8);
-                return 0;
-        }
-        printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
-        return 1;
+		/* configure pin GPD8 as output and set to 0 */
+		gpio->PDCON &= ~(0x3 << 8*2);
+		gpio->PDCON |= (0x1 << 8*2);
+		gpio->PDDAT &= ~(1 << 8);
+		return 0;
+	}
+	printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+	return 1;
 }
 
 
 int do_thermo (char **argv)
 {
-        int     channel, res;
+	int     channel, res;
 
-        tsc2000_reg_init ();
-        tsc2000_set_range (3);
+	tsc2000_reg_init ();
 
-        if (strcmp (argv[2], "all") == 0) {
-                int i;
-                for (i=0; i <= 15; i++) {
-                        res = tsc2000_read_channel(i);
-                        print_identifier ();
-                        printf ("c%d: %d\n", i, res);
-                }
-                return 0;
-        }
-        channel = simple_strtoul (argv[2], NULL, 10);
-        res = tsc2000_read_channel(channel);
-        print_identifier ();
-        printf ("%d\n", res);
-        return 0;                 /* return OK */
+	if (strcmp (argv[2], "all") == 0) {
+		int i;
+		for (i=0; i <= 15; i++) {
+			res = tsc2000_read_channel(i);
+			print_identifier ();
+			printf ("c%d: %d\n", i, res);
+		}
+		return 0;
+	}
+	channel = simple_strtoul (argv[2], NULL, 10);
+	res = tsc2000_read_channel(channel);
+	print_identifier ();
+	printf ("%d\n", res);
+	return 0;                 /* return OK */
 }
 
 
 
 int do_touch (char **argv)
 {
-        int     x, y;
+	int     x, y;
 
-        if (strcmp (argv[2], "tl") == 0) {
-                touch_wait_pressed();
-                touch_read_x_y (&x, &y);
+	if (strcmp (argv[2], "tl") == 0) {
+#if CONFIG_TOUCH_WAIT_PRESSED
+		touch_wait_pressed();
+#else
+		{
+			int i;
+			for (i = 0; i < (TOUCH_TIMEOUT * 1000); i++) {
+				if (touch_check_pressed ()) {
+					break;
+				}
+				udelay (1000);  /* pause 1 ms */
+			}
+		}
+		if (!touch_check_pressed()) {
+			print_identifier ();
+			printf ("error: touch not pressed\n");
+			return 1;
+		}
+#endif /* CONFIG_TOUCH_WAIT_PRESSED */
+		touch_read_x_y (&x, &y);
 
-                print_identifier ();
-                printf ("x=%d y=%d\n", x, y);
-                return touch_write_clibration_values (CALIB_TL, x, y);
-        }
-        else if (strcmp (argv[2], "dr") == 0) {
-                touch_wait_pressed();
-                touch_read_x_y (&x, &y);
+		print_identifier ();
+		printf ("x=%d y=%d\n", x, y);
+		return touch_write_clibration_values (CALIB_TL, x, y);
+	}
+	else if (strcmp (argv[2], "dr") == 0) {
+#if CONFIG_TOUCH_WAIT_PRESSED
+		touch_wait_pressed();
+#else
+		{
+			int i;
+			for (i = 0; i < (TOUCH_TIMEOUT * 1000); i++) {
+				if (touch_check_pressed ()) {
+					break;
+				}
+				udelay (1000);  /* pause 1 ms */
+			}
+		}
+		if (!touch_check_pressed()) {
+			print_identifier ();
+			printf ("error: touch not pressed\n");
+			return 1;
+		}
+#endif /* CONFIG_TOUCH_WAIT_PRESSED */
+		touch_read_x_y (&x, &y);
 
-                print_identifier ();
-                printf ("x=%d y=%d\n", x, y);
+		print_identifier ();
+		printf ("x=%d y=%d\n", x, y);
 
-                return touch_write_clibration_values (CALIB_DR, x, y);
-        }
-        return 1;                 /* return error */
+		return touch_write_clibration_values (CALIB_DR, x, y);
+	}
+	return 1;                 /* not "tl", nor "dr", so return error */
 }
 
 
+#ifdef CONFIG_TOUCH_WAIT_PRESSED
 static void touch_wait_pressed (void)
 {
-        while (!(tsc2000_read(TSC2000_REG_ADC) & TC_PSM));
+	while (!(tsc2000_read(TSC2000_REG_ADC) & TC_PSM));
 }
 
+#else
+static int touch_check_pressed (void)
+{
+	return (tsc2000_read(TSC2000_REG_ADC) & TC_PSM);
+}
+#endif /* CONFIG_TOUCH_WAIT_PRESSED */
 
 static int touch_write_clibration_values (int calib_point, int x, int y)
 {
 #if (CONFIG_COMMANDS & CFG_CMD_I2C)
-     tsc2000_reg_init ();
+	int x_verify = 0;
+	int y_verify = 0;
 
-        if (calib_point == CALIB_TL) {
-                if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_X0, 1,
-                               (char *)&x, 2)) {
-                        printf ("could not write to eeprom\n");
-                        return 1;
-                }
-                udelay(11000);
-                if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_Y0, 1,
-                               (char *)&y, 2)) {
-                        printf ("could not write to eeprom\n");
-                        return 1;
-                }
-                udelay(11000);
-                return 0;
-        }
-        else if (calib_point == CALIB_DR) {
-                  if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_X1, 1,
-                               (char *)&x, 2)) {
-                          printf ("could not write to eeprom\n");
-                        return 1;
-                  }
-                udelay(11000);
-                if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_Y1, 1,
-                               (char *)&y, 2)) {
-                        printf ("could not write to eeprom\n");
-                        return 1;
-                }
-                udelay(11000);
-                return 0;
-        }
-        return 1;
+	tsc2000_reg_init ();
+
+	if (calib_point == CALIB_TL) {
+		if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X0, 1,
+			       (char *)&x, 2)) {
+			return 1;
+		}
+		if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y0, 1,
+			       (char *)&y, 2)) {
+			return 1;
+		}
+
+		/* verify written values */
+		if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X0, 1,
+			      (char *)&x_verify, 2)) {
+			return 1;
+		}
+		if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y0, 1,
+			       (char *)&y_verify, 2)) {
+			return 1;
+		}
+		if ((y != y_verify) || (x != x_verify)) {
+			print_identifier ();
+			printf ("error: verify error\n");
+			return 1;
+		}
+		return 0;       /* no error */
+	}
+	else if (calib_point == CALIB_DR) {
+		  if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X1, 1,
+			       (char *)&x, 2)) {
+			return 1;
+		  }
+		if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y1, 1,
+			       (char *)&y, 2)) {
+			return 1;
+		}
+
+		/* verify written values */
+		if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X1, 1,
+				       (char *)&x_verify, 2)) {
+			return 1;
+		}
+		if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y1, 1,
+			       (char *)&y_verify, 2)) {
+			return 1;
+		}
+		if ((y != y_verify) || (x != x_verify)) {
+			print_identifier ();
+			printf ("error: verify error\n");
+			return 1;
+		}
+		return 0;
+	}
+	return 1;
 #else
-        printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
-                "to EEPROM\n");
-        return (1);
+	printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+		"to EEPROM\n");
+	return (1);
 #endif /* CFG_CMD_I2C */
 }
 
 
 static void touch_read_x_y (int *px, int *py)
 {
-        tsc2000_write(TSC2000_REG_ADC, DEFAULT_ADC | TC_AD0 | TC_AD1);
-        adc_wait_conversion_done();
-        *px = tsc2000_read(TSC2000_REG_X);
+	tsc2000_write(TSC2000_REG_ADC, DEFAULT_ADC | TC_AD0 | TC_AD1);
+	adc_wait_conversion_done();
+	*px = tsc2000_read(TSC2000_REG_X);
 
-        tsc2000_write(TSC2000_REG_ADC, DEFAULT_ADC | TC_AD2);
-        adc_wait_conversion_done();
-        *py = tsc2000_read(TSC2000_REG_Y);
+	tsc2000_write(TSC2000_REG_ADC, DEFAULT_ADC | TC_AD2);
+	adc_wait_conversion_done();
+	*py = tsc2000_read(TSC2000_REG_Y);
 }
 
 
 
 int do_rs485 (char **argv)
 {
-        int timeout;
-        char data[RS485_MAX_RECEIVE_BUF_LEN];
+	int timeout;
+	char data[RS485_MAX_RECEIVE_BUF_LEN];
 
-        if (strcmp (argv[2], "send") == 0) {
-                return (rs485_send_line (argv[3]));
-        }
-        else if (strcmp (argv[2], "receive") == 0) {
-                timeout = simple_strtoul(argv[3], NULL, 10);
-                if (rs485_receive_chars (data, timeout) != 0) {
-                        print_identifier ();
-                        printf ("## nothing received\n");
-                        return (1);
-                }
-                else {
-                        print_identifier ();
-                        printf ("%s\n", data);
-                        return (0);
-                }
-        }
-        printf ("%s: unknown command %s\n", __FUNCTION__, argv[2]);
-        return (1);             /* unknown command, return error */
+	if (strcmp (argv[2], "send") == 0) {
+		return (rs485_send_line (argv[3]));
+	}
+	else if (strcmp (argv[2], "receive") == 0) {
+		timeout = simple_strtoul(argv[3], NULL, 10);
+		if (rs485_receive_chars (data, timeout) != 0) {
+			print_identifier ();
+			printf ("## nothing received\n");
+			return (1);
+		}
+		else {
+			print_identifier ();
+			printf ("%s\n", data);
+			return (0);
+		}
+	}
+	printf ("%s: unknown command %s\n", __FUNCTION__, argv[2]);
+	return (1);             /* unknown command, return error */
 }
 
 
 static int rs485_send_line (const char *data)
 {
-        rs485_init ();
-        trab_rs485_enable_tx ();
-        rs485_puts (data);
-        rs485_putc ('\n');
+	rs485_init ();
+	trab_rs485_enable_tx ();
+	rs485_puts (data);
+	rs485_putc ('\n');
 
-        return (0);
+	return (0);
 }
 
 
 static int rs485_receive_chars (char *data, int timeout)
 {
-        int i;
-        int receive_count = 0;
+	int i;
+	int receive_count = 0;
 
-        rs485_init ();
-        trab_rs485_enable_rx ();
+	rs485_init ();
+	trab_rs485_enable_rx ();
 
-        /* test every 1 ms for received characters to avoid a receive FIFO
-         * overrun (@ 38.400 Baud) */
-        for (i = 0; i < (timeout * 1000); i++) {
-                while (rs485_tstc ()) {
-                        if (receive_count >= RS485_MAX_RECEIVE_BUF_LEN-1)
-                                break;
-                        *data++ = rs485_getc ();
-                        receive_count++;
-                }
-                udelay (1000);  /* pause 1 ms */
-        }
-        *data = '\0';           /* terminate string */
+	/* test every 1 ms for received characters to avoid a receive FIFO
+	 * overrun (@ 38.400 Baud) */
+	for (i = 0; i < (timeout * 1000); i++) {
+		while (rs485_tstc ()) {
+			if (receive_count >= RS485_MAX_RECEIVE_BUF_LEN-1)
+				break;
+			*data++ = rs485_getc ();
+			receive_count++;
+		}
+		udelay (1000);  /* pause 1 ms */
+	}
+	*data = '\0';           /* terminate string */
 
-        if (receive_count == 0)
-                return (1);
-        else
-                return (0);
+	if (receive_count == 0)
+		return (1);
+	else
+		return (0);
 }
 
 
 int do_serial_number (char **argv)
 {
 #if (CONFIG_COMMANDS & CFG_CMD_I2C)
-        unsigned int serial_number;
+	unsigned int serial_number;
 
-        if (strcmp (argv[2], "read") == 0) {
-                if (i2c_read (I2C_EEPROM_DEV_ADDR, SERIAL_NUMBER, 1,
-                              (char *)&serial_number, 4)) {
-                        printf ("could not read from eeprom\n");
-                        return (1);
-                }
-                print_identifier ();
-                printf ("%08d\n", serial_number);
-                return (0);
-        }
-        else if (strcmp (argv[2], "write") == 0) {
-                serial_number = simple_strtoul(argv[3], NULL, 10);
-                if (i2c_write (I2C_EEPROM_DEV_ADDR, SERIAL_NUMBER, 1,
-                              (char *)&serial_number, 4)) {
-                        printf ("could not write to eeprom\n");
-                        return (1);
-                }
-                return (0);
-        }
-        printf ("%s: unknown command %s\n", __FUNCTION__, argv[2]);
-        return (1);             /* unknown command, return error */
+	if (strcmp (argv[2], "read") == 0) {
+		if (i2c_read (I2C_EEPROM_DEV_ADDR, SERIAL_NUMBER, 1,
+			      (char *)&serial_number, 4)) {
+			printf ("could not read from eeprom\n");
+			return (1);
+		}
+		print_identifier ();
+		printf ("%08d\n", serial_number);
+		return (0);
+	}
+	else if (strcmp (argv[2], "write") == 0) {
+		serial_number = simple_strtoul(argv[3], NULL, 10);
+		if (i2c_write (I2C_EEPROM_DEV_ADDR, SERIAL_NUMBER, 1,
+			      (char *)&serial_number, 4)) {
+			printf ("could not write to eeprom\n");
+			return (1);
+		}
+		return (0);
+	}
+	printf ("%s: unknown command %s\n", __FUNCTION__, argv[2]);
+	return (1);             /* unknown command, return error */
 #else
-        printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
-                "to EEPROM\n");
-        return (1);
+	printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+		"to EEPROM\n");
+	return (1);
 #endif /* CFG_CMD_I2C */
 }
 
@@ -991,29 +1142,29 @@
 int do_crc16 (void)
 {
 #if (CONFIG_COMMANDS & CFG_CMD_I2C)
-        int crc;
-        char buf[EEPROM_MAX_CRC_BUF];
+	int crc;
+	char buf[EEPROM_MAX_CRC_BUF];
 
-        if (i2c_read (I2C_EEPROM_DEV_ADDR, 0, 1, buf, 60)) {
-                printf ("could not read from eeprom\n");
-                return (1);
-        }
-        crc = 0;                /* start value of crc calculation */
-        crc = updcrc (crc, buf, 60);
+	if (i2c_read (I2C_EEPROM_DEV_ADDR, 0, 1, buf, 60)) {
+		printf ("could not read from eeprom\n");
+		return (1);
+	}
+	crc = 0;                /* start value of crc calculation */
+	crc = updcrc (crc, buf, 60);
 
-        print_identifier ();
-        printf ("crc16=%#04x\n", crc);
+	print_identifier ();
+	printf ("crc16=%#04x\n", crc);
 
-        if (i2c_write (I2C_EEPROM_DEV_ADDR, CRC16, 1, (char *)&crc,
-                       sizeof (crc))) {
-                printf ("could not read from eeprom\n");
-                return (1);
-        }
-        return (0);
+	if (i2c_write (I2C_EEPROM_DEV_ADDR, CRC16, 1, (char *)&crc,
+		       sizeof (crc))) {
+		printf ("could not read from eeprom\n");
+		return (1);
+	}
+	return (0);
 #else
-        printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
-                "to EEPROM\n");
-        return (1);
+	printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+		"to EEPROM\n");
+	return (1);
 #endif /* CFG_CMD_I2C */
 }
 
@@ -1080,14 +1231,183 @@
     };
 
 static unsigned short updcrc(unsigned short icrc, unsigned char *icp,
-                             unsigned int icnt )
+			     unsigned int icnt )
 {
-        register unsigned short crc = icrc;
-        register unsigned char *cp = icp;
-        register unsigned int cnt = icnt;
+	register unsigned short crc = icrc;
+	register unsigned char *cp = icp;
+	register unsigned int cnt = icnt;
 
-        while (cnt--)
-                crc = (crc<<B) ^ crctab[(crc>>(W-B)) ^ *cp++];
+	while (cnt--)
+		crc = (crc<<B) ^ crctab[(crc>>(W-B)) ^ *cp++];
 
-        return (crc);
+	return (crc);
 }
+
+
+int do_gain (char **argv)
+{
+	int range;
+
+	range = simple_strtoul (argv[2], NULL, 10);
+	if ((range < 1) || (range > 3))
+	{
+		printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+		return 1;
+	}
+
+	tsc2000_set_range (range);
+	return (0);
+}
+
+
+int do_eeprom (char **argv)
+{
+#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+	if (strcmp (argv[2], "read") == 0) {
+		return (trab_eeprom_read (argv));
+	}
+
+	else if (strcmp (argv[2], "write") == 0) {
+		return (trab_eeprom_write (argv));
+	}
+
+	printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+	return (1);
+#else
+	printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+		"to EEPROM\n");
+	return (1);
+#endif /* CFG_CMD_I2C */
+}
+
+#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+static int trab_eeprom_read (char **argv)
+{
+	int i;
+	int len;
+	unsigned int addr;
+	long int value = 0;
+	uchar *buffer;
+
+	buffer = (uchar *) &value;
+	addr = simple_strtoul (argv[3], NULL, 10);
+	addr &= 0xfff;
+	len = simple_strtoul (argv[4], NULL, 10);
+	if ((len < 1) || (len > 4)) {
+		printf ("%s: invalid parameter %s\n", __FUNCTION__,
+			argv[4]);
+		return (1);
+	}
+	for (i = 0; i < len; i++) {
+		if (i2c_read (I2C_EEPROM_DEV_ADDR, addr+i, 1, buffer+i, 1)) {
+			printf ("%s: could not read from i2c device %#x"
+				", addr %d\n", __FUNCTION__,
+				I2C_EEPROM_DEV_ADDR, addr);
+			return (1);
+		}
+	}
+	print_identifier ();
+	if (strcmp (argv[5], "-") == 0) {
+		if (len == 1)
+			printf ("%d\n", (signed char) value);
+		else if (len == 2)
+			printf ("%d\n", (signed short int) value);
+		else
+			printf ("%ld\n", value);
+	}
+	else {
+		if (len == 1)
+			printf ("%d\n", (unsigned char) value);
+		else if (len == 2)
+			printf ("%d\n", (unsigned short int) value);
+		else
+			printf ("%ld\n", (unsigned long int) value);
+	}
+	return (0);
+}
+
+static int trab_eeprom_write (char **argv)
+{
+	int i;
+	int len;
+	unsigned int addr;
+	long int value = 0;
+	uchar *buffer;
+
+	buffer = (uchar *) &value;
+	addr = simple_strtoul (argv[3], NULL, 10);
+	addr &= 0xfff;
+	len = simple_strtoul (argv[4], NULL, 10);
+	if ((len < 1) || (len > 4)) {
+		printf ("%s: invalid parameter %s\n", __FUNCTION__,
+			argv[4]);
+		return (1);
+	}
+	value = simple_strtol (argv[5], NULL, 10);
+	debug ("value=%ld\n", value);
+	for (i = 0; i < len; i++) {
+		if (i2c_write (I2C_EEPROM_DEV_ADDR, addr+i, 1, buffer+i, 1)) {
+			printf ("%s: could not write to i2c device %d"
+				", addr %d\n", __FUNCTION__,
+				I2C_EEPROM_DEV_ADDR, addr);
+			return (1);
+		}
+#if 0
+		printf ("chip=%#x, addr+i=%#x+%d=%p, alen=%d, *buffer+i="
+			"%#x+%d=%p=%#x \n",I2C_EEPROM_DEV_ADDR_DEV_ADDR , addr,
+			i, addr+i, 1, buffer, i, buffer+i, *(buffer+i));
+#endif
+		udelay (30000); /* wait for EEPROM ready */
+	}
+	return (0);
+}
+
+int i2c_write_multiple (uchar chip, uint addr, int alen,
+			uchar *buffer, int len)
+{
+	int i;
+
+	if (alen != 1) {
+		printf ("%s: addr len other than 1 not supported\n",
+			 __FUNCTION__);
+		return (1);
+	}
+
+	for (i = 0; i < len; i++) {
+		if (i2c_write (chip, addr+i, alen, buffer+i, 1)) {
+			printf ("%s: could not write to i2c device %d"
+				 ", addr %d\n", __FUNCTION__, chip, addr);
+			return (1);
+		}
+#if 0
+		printf ("chip=%#x, addr+i=%#x+%d=%p, alen=%d, *buffer+i="
+			"%#x+%d=%p=\"%.1s\"\n", chip, addr, i, addr+i,
+			alen, buffer, i, buffer+i, buffer+i);
+#endif
+
+		udelay (30000);
+	}
+	return (0);
+}
+
+int i2c_read_multiple ( uchar chip, uint addr, int alen,
+			uchar *buffer, int len)
+{
+	int i;
+
+	if (alen != 1) {
+		printf ("%s: addr len other than 1 not supported\n",
+			 __FUNCTION__);
+		return (1);
+	}
+
+	for (i = 0; i < len; i++) {
+		if (i2c_read (chip, addr+i, alen, buffer+i, 1)) {
+			printf ("%s: could not read from i2c device %#x"
+				 ", addr %d\n", __FUNCTION__, chip, addr);
+			return (1);
+		}
+	}
+	return (0);
+}
+#endif /* CFG_CMD_I2C */
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 972ef33d..1f27133 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -33,6 +33,11 @@
 
 #if (CONFIG_COMMANDS & CFG_CMD_FAT)
 
+#ifdef CONFIG_AUTO_UPDATE
+/* the VFAT code has a bug which breaks auto update */
+#undef CONFIG_SUPPORT_VFAT
+#endif
+
 /*
  * Convert a string to lowercase.
  */
diff --git a/include/configs/trab.h b/include/configs/trab.h
index e6b43d6..86c3f83 100644
--- a/include/configs/trab.h
+++ b/include/configs/trab.h
@@ -182,7 +182,7 @@
 #define CONFIG_IPADDR		192.168.3.68
 #define CONFIG_HOSTNAME		trab
 #define CONFIG_SERVERIP		192.168.3.1
-#define CONFIG_BOOTCOMMAND	"run flash_nfs"
+#define CONFIG_BOOTCOMMAND	"burn_in"
 
 #ifndef CONFIG_FLASH_8MB	/* current config: 16 MB flash */
 #ifdef CFG_HUSH_PARSER
@@ -331,9 +331,13 @@
 #define CONFIG_MISC_INIT_R		/* have misc_init_r() function	*/
 
 /*-----------------------------------------------------------------------
- * burn-in test stuff
+ * burn-in test stuff.
+ *  
+ * BURN_IN_CYCLE_DELAY defines the seconds to wait between each burn-in cycle
+ * Because the burn-in test itself causes also an delay of about 4 seconds,
+ * this time must be subtracted from the desired overall burn-in cycle time.
  */
-#define BURN_IN_CYCLE_DELAY	20	/* delay in sec between burn-in test cycles */
+#define BURN_IN_CYCLE_DELAY	296	/* seconds between burn-in cycles */
 
 /*-----------------------------------------------------------------------
  * Stack sizes
